﻿Imports System.Runtime.CompilerServices
Imports StandAuto.DesktopApi.ModuleExtentrions
Public Class Utilitarios
    Public Shared Function BuscarListaPesquisada(Of T)(listaPesquisar As List(Of T), textoPesquisa As String) As List(Of T)

        If String.IsNullOrWhiteSpace(textoPesquisa) Then
            Return listaPesquisar
        End If

        Dim listaRet As List(Of T) = New List(Of T)()

        listaPesquisar.ForEach(
            Function(z)
                If z.GetType().GetProperties().
                                    Any(Function(y)
                                            If y.GetValue(z) Is Nothing Then
                                                Return False
                                            End If
                                            Return y.GetValue(z).ToString().ContainsIgnoreCase(textoPesquisa)
                                        End Function) Then
                    listaRet.Add(z)
                End If
                Return True
            End Function)
        Return listaRet
    End Function
End Class
